//
//  MEPrototype.h
//  MapEditor
//
//  Created by Eric on 3/3/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "cocos2d.h"
#import "Box2D.h"
#import <map>

@interface MEPrototype : NSObject{
    NSString* className;
    NSInteger sid;
    NSInteger fileType;
    NSString *filePath;
    NSString *name;
    NSImage *image;
    
    BOOL isBox2dObj;
    CGFloat density;
    CGFloat friction;
    CGFloat restitution;
    
    NSInteger bodyType;
    NSInteger shapeIndex;
    NSMutableArray *shapes;
    CGPoint shapeCenter; 
    
    BOOL isSoftBody;
    NSInteger segmentsNum;
    CGFloat frequencyHzOut;
    CGFloat dampingRatioOut;
    CGFloat frequencyHzIn;
    CGFloat dampingRatioIn;
    
    CGFloat innerRateX;
    CGFloat innerRateY;
}
@property(nonatomic, retain)NSString* className;
@property(nonatomic)NSInteger sid;
@property(nonatomic)NSInteger fileType;

@property(nonatomic, retain)NSString* filePath;
@property(nonatomic, retain)NSString *name;
@property(nonatomic, retain)NSImage *image;


@property(nonatomic)BOOL isBox2dObj;
@property(nonatomic)CGFloat density;
@property(nonatomic)CGFloat friction;
@property(nonatomic)CGFloat restitution;

@property(nonatomic)NSInteger bodyType;
@property(nonatomic)NSInteger shapeIndex;
@property(nonatomic, retain)NSMutableArray *shapes;
@property(nonatomic)CGPoint shapeCenter; 

@property(nonatomic)BOOL isSoftBody;
@property(nonatomic)NSInteger segmentsNum;
@property(nonatomic)CGFloat frequencyHzOut;
@property(nonatomic)CGFloat dampingRatioOut;
@property(nonatomic)CGFloat frequencyHzIn;
@property(nonatomic)CGFloat dampingRatioIn;
@property(nonatomic)CGFloat innerRateX;
@property(nonatomic)CGFloat innerRateY;

+(id)prototype;
+(id)prototypeWithParam:(NSDictionary*)param;
-(NSMutableDictionary*)toDict;
@end


@interface MEPrototypeParam : MEPrototype {
    CGFloat rotation;
    CGFloat scale;
    CGPoint pos;
    
    BOOL flipX;
    BOOL flipY;
}
@property(nonatomic)CGFloat rotation;
@property(nonatomic)CGFloat scale;
@property(nonatomic)CGPoint pos;
@property(nonatomic)BOOL flipX;
@property(nonatomic)BOOL flipY;

+(id)prototypeParamWithDict:(NSDictionary*)param;
+(id)prototypeParamWithPrototype:(MEPrototype*)prototype;
@end



@interface MEPrototypeMgr : NSObject {
    NSInteger sidCount;
    NSMutableDictionary* prototypeDict;
}
@property(nonatomic, retain)NSMutableDictionary* prototypeDict;
+(id)instance;
-(id)createPrototype;
-(void)removePrototype:(MEPrototype*)prototype;
-(void)removeAllPrototypes;

-(id)dictToPrototype:(NSDictionary*)param;
-(id)duplicate:(MEPrototype*)prototype;
-(id)prototypeWithSid:(NSInteger)sid;
@end